const fs = require('fs')
const promisify = require('util').promisify
/* fs.readFile('./file/1.txt', (err, data) => {
    console.log(data.toString());
}) */

/* function readFile(path) {
    return new Promise((resolve, reject) => {
        fs.readFile(path, (err, data) => {
            if (err) return reject(err);
            resolve(data);
        })
    })
} */

const readFile = promisify(fs.readFile);
readFile('../file/1.txt').then(data => console.log(data.toString())).catch(err => console.log(err))

async function getFile() {
    const data = await readFile('../file/1.txt');
    console.log(data.toString());
}

// getFile();

(async () => {
    try {
        const data = await readFile('../file/1.txt');
        console.log(data.toString());
    } catch (error) {
        console.log(error);
    }
})();


function* generator(value) {
    yield console.log(value + 1);
    yield console.log(value + 2);
}
const gen = generator(2);
setInterval(() => {
    gen.next();
}, 1000);

